/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package scrabble;

import java.awt.GridLayout;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

   
   
/**
 *
 * @author KhoufiAsma
 */
public class Plateau extends JPanel{
 
    public CaseVide[][] board = new CaseVide[15][15];
    private String[] tab = new String[6];
    //private char[][] plat = new char[15][15];
    private int[][] pos = new int[2][7];
   private  int ipos;
    private Dictionnaire D = new Dictionnaire(Fenetre.langue);
   private Fenetre.MyDropTargetListener myDropTargetListener;
   private int valeurMot;
   public  int nb=0;
   private Chevalet ch;

   
   public Plateau(Fenetre.MyDropTargetListener md,Chevalet ch){
     this.setSize(100, 100);
     this.setBounds(440,50, 616, 616);
     this.setLayout(new GridLayout(15,15));
      myDropTargetListener=md;
      this.ch=ch;
     
           ConstruirePlateau();
           
        
       }
   
   public int getValeurMot()
   {
       return valeurMot;
   }
   
   int orientation()
   {
       int d=0;
       for(int i=0;i<6;i++)
    {
        if(pos[0][i]!=-1&&pos[0][i+1]!=-1)
        {
          if(pos[0][i]!=pos[0][i+1])
          {
              d=1;
              break;
          }
        }
    }
       return d;
   }

   //verifier si la lettre appartient au tableau pos
   public boolean dans_pos(int x,int y)
   {
       for(int i=0;i<7;i++)
       {
        if(pos[0][i]==x&&pos[1][i]==y) 
            return true;
       }
       
       
     return false;  
   }
   
//retourner la plus grande valeur de l'indice de la ligne et de la colonne 
   public int maxl() 
   {
     int l=pos[0][0];
     for(int i=0;i<7;i++)
         if(pos[0][i]>l)
            l=pos[0][i];
     return l;
   }
   
   
   public int maxc()
   {
     int c=pos[1][0];
     for(int i=0;i<7;i++)
         if(pos[1][i]>c)
            c=pos[1][i];
     return c;
   }
     
     
   
   
   
   //retourner la plus petite valeur de l'indice de la ligne et de la colonne 
   public int minl()
   {
       int l=pos[0][0];
     for(int i=0;i<7;i++)
     {
         if(pos[0][i]<l&&pos[0][i]!=-1)
            l=pos[0][i];
     }
     return l;
   }
    public int minc()
   { 
     int c=pos[1][0];
     for(int i=0;i<7;i++)
     {
         if(pos[1][i]<c&&pos[1][i]!=-1)
            c=pos[1][i];
     }
     return c;
       
   }
   
   //le nombre de coups
   public void getnb()
   {
       nb++;
   }
   
   
   public boolean attacher_mot(int d)
   {
       if(nb==0)
           return true;
       else
       {
       int l ,l1 ,c ,c1 ;
       l=maxl();
       l1=minl();
       c=maxc();
       c1=minc();
       if(d==0)
       {
       if(c1!=0&&board[l][c1-1].getLettre()!=null)
           return true;
       if(c!=14&&board[l][c+1].getLettre()!=null)
           return true;
       if(l!=14&&l1!=0)
       {
           for(int i=c1;i<=c;i++)
           {
               if(board[l-1][i].getLettre()!=null||board[l+1][i].getLettre()!=null)
                   return true;
           }
       }
       if(l==0)
       {
           for(int i=c1;i<=c;i++)
           {
               if(board[l+1][i].getLettre()!=null)
                   return true;
           }
       }
       if(l==14)
       {
           for(int i=c1;i<=c;i++)
           {
               if(board[l-1][i].getLettre()!=null)
                   return true;
           }
       }
       
       }
       else
       {
           if(l1!=0&&board[l1-1][c].getLettre()!=null)
                return true;
           if(l!=14&&board[l+1][c].getLettre()!=null)
                return true;
       if(c!=14&&c1!=0)
       {
           for(int i=l1;i<=l;i++)
           {
               if(board[i][c-1].getLettre()!=null||board[i][c+1].getLettre()!=null)
                   return true;
           }
       }
       
       if(c1==0)
       {
         for(int i=l1;i<=l;i++)
           {
               if(board[i][c+1].getLettre()!=null)
                   return true;
           }  
       }
       if(c==14)
       {
           for(int i=l1;i<=l;i++)
           {
               if(board[i][c-1].getLettre()!=null)
                   return true;
           }
       }
           
       }
       
           
       }
       
       return false;
   }
   
   //retourner le nombre de lettres jouées
   public int nb_lettres_joue()
   {
       int comp=0;
       for(int i=0;i<7;i++)
       {
           if(pos[0][i]!=-1&&pos[1][i]!=-1)
           comp++;
       }
       return comp;
   }
   
   //verifier si le mot est valide
   boolean motvalide()
   {
       int x = 0,y = 0,x1 = 0,y1 = 0,j;
       String[] t =new String[7];
       String[] t1 =new String[7];
       
       //initialiser le tableau qui contient les nouveaux mots
       for(int i=0;i<7;i++)
        {
            t[i]="";
            t1[i]="";
        }
       
       
       for(int i=0;i<7;i++)
       {
           
           if(pos[0][i]!=-1)
           {
               //rechercher le debut du mot en vertical
               j=pos[0][i];
               while(j!=0&&board[j-1][pos[1][i]].getLettre()!=null)
               {
               j--;  
               }
               x=j;
               //rechercher la fin du mot en vertical
               j=pos[0][i];
               while(j!=14&&board[j+1][pos[1][i]].getLettre()!=null)
               {
               j++;   
               }
               x1=j;
           }
           
           if(pos[1][i]!=-1&&pos[0][i]!=-1)
           {
               //rechercher le debut du mot en horizontal
               j=pos[1][i];
               while(j!=0&&board[pos[0][i]][j-1].getLettre()!=null)
               j--;   
               y=j;
               //rechercher la fin du mot en horizontal
               j=pos[1][i];
               while(j!=14&&board[pos[0][i]][j+1].getLettre()!=null)
               j++;   
               y1=j;
           }
           
           
           
           //mettre les nouveaux mots dans le tableau t
           if(pos[0][i]!=-1&&pos[1][i]!=-1)
           {
               if(y!=y1)
               {
                  
                   for(int k=y;k<=y1;k++)
                   {
                     if(board[pos[0][i]][k].getLettre()!=null)
                   { 
                       
                      t1[i]+=board[pos[0][i]][k].getLettre().getNom();
                    
                   }
                   
                   
                   }
               }
           }
           
           
           if(pos[0][i]!=-1&&pos[1][i]!=-1)
           {
               if(x!=x1)
               {
                  
                   for(int k=x;k<=x1;k++)
                   {if(board[k][pos[1][i]].getLettre()!=null)
                   { t[i]+=(board[k][pos[1][i]].getLettre()).getNom();  
                    
                   }
                   
                   }
                   
               }

           }
           
       }
     
       //verifier si les mots construits appartiennet au dictionnaire
       for(int i=0;i<7;i++)
       {
           
           if(!"".equals(t[i]))
           {
           if(D.VérifierMot(t[i].toLowerCase())==false)
               return false;
           }
           if(!"".equals(t1[i]))
           {
           if(D.VérifierMot(t1[i].toLowerCase())==false)
               return false;
           }
               
       }
       return true;
   }
   
   
 //verifier si les lettres du mots sont attachées
 public boolean attacher(int d)
 {
    if(nb_lettres_joue()!=1)
    {
       int l,l1,c,c1;
       l=maxl();
       l1=minl();
       c=maxc();
       c1=minc();
        if(d==0)
        {
            for(int i=l1;i<l;i++)
            {
                if(board[i+1][c].getLettre()==null)
                    return false;
            }
                
        }
        else
        {
             for(int i=c1;i<c;i++)
            {
                if(board[l][i+1].getLettre()==null)
                    return false;
            }
        }
     
     return true;
    }
    else
        return true;
 }
   
 
 
//verifier toutes les conditions 
 public boolean valide()
 {
     boolean v=true;
     
     int d = 0,l=-1,c=-1,l1=-1,c1=-1;
     if(nb_lettres_joue()==0)
     {
         JOptionPane.showMessageDialog(null,"Veillez jouer un coup SVP");
         return false;
     }
      //verifier le premier coups
    if(board[7][7].getLettre()==null)
    {
        JOptionPane.showMessageDialog(null,"Le mot doit passer par la case du milieu");
      
        return false;
    }
    //savoir l'orientation du mot
    for(int i=0;i<6;i++)
    {
        if(pos[0][i]!=-1&&pos[0][i+1]!=-1)
        {
          if(pos[0][i]!=pos[0][i+1])
          {
              d=1;
              v=false;
              break;
          }
        }
    }
        if(!v)
        {
          for(int i=0;i<6;i++)
    {
        if(pos[1][i]!=-1&&pos[1][i+1]!=-1)
        {
          if(pos[1][i]!=pos[1][i+1])
          {
              JOptionPane.showMessageDialog(null,"lettres mal alignées");
           
             return false;
          }
        }
    }  
        }
      
        if(d==0)
        {
            l=maxl();
            l1=minl();
            c=maxc();
            c1=minc();
         
         for(int i=c1;i<c;i++)
         {
             if(board[l][i+1].getLettre()==null)
             {JOptionPane.showMessageDialog(null,"les lettres doivent se toucher");
       
                 return false;
             }
         }
             
         
        }
        else
        {
            l=maxl();
            l1=minl();
            c=maxc();
            c1=minc();
         
         for(int i=l1;i<l;i++)
         {
             if(board[i+1][c].getLettre()==null)
             {
                 JOptionPane.showMessageDialog(null,"Les lettres doivent se toucher");
                 
                 return false;
             }
         }
             
          
        }
        
 if(d==0)
 {
    if(attacher(0)==false) 
    {
        JOptionPane.showMessageDialog(null,"les lettres doivent se toucher");
       
        return false;
    }
    if(attacher_mot(0)==false)
    {
        JOptionPane.showMessageDialog(null,"le mot construit doit toucher un autre mot");
       
        return false;
    }
 }
 
 if(d==1)
 {
     if(attacher(1)==false)
     {
        JOptionPane.showMessageDialog(null,"les lettres doivent se toucher");
   
        return false;
        
     }
      if(attacher_mot(1)==false)
      {
        JOptionPane.showMessageDialog(null,"le mot construit doit toucher un autre mot");
        
        return false;
      }
 }
if(!motvalide())
{
    JOptionPane.showMessageDialog(null,"le mot construit est invalide");
    
     return false;
}

            
    return true;
 }
 
  public int comptage(int d)
 {
     int s=0,l,l1,c,c1,p=1,j,x,x1,s1=0,p1=1,s2=0,a = 0,b = 0;
     if(nb_lettres_joue()==1)
     {boolean v=true;
        for(int i=0;i<7;i++)
        {
            if(pos[0][i]!=-1)
            {
                a=pos[0][i];
                b=pos[1][i];
            }
        }
    if(a!=0)
    {
     if(board[a-1][b].getLettre()!=null) 
     {
         v=false;
     }
    }
    if(a!=14)
    {
     if(board[a+1][b].getLettre()!=null) 
     {
         v=false;
     }
    }
    if(v==false)
    {
            l1=0;
            l=14;
            c=b;
            while(board[l1][c].getLettre()==null)
            {
                l1++;
            }
            while(board[l][c].getLettre()==null)
            {
                l--;
            }

            for(int i=l1;i<=l;i++)
            {
                if(dans_pos(i,c)==true)
                {
                 s+=board[i][c].getValLettre()*board[i][c].getLettre().getValeur();
                 p*=board[i][c].getValMot();
                 
                }
                else
                {
                   s+=board[i][c].getLettre().getValeur();
                  
                }
            }
            s*=p; 
    }
            v=true;
    if(b!=0)
    {
     if(board[a][b-1].getLettre()!=null)
     {
         v=false;
     }
    }  
     if(b!=14)
    {
     if(board[a][b+1].getLettre()!=null)  
     {
         v=false;
     }
    }
     if(!v)
     {
            l=a;
            c1=0;
            c=14;
            while(board[l][c1].getLettre()==null)
            {
                c1++;
            }
            while(board[l][c].getLettre()==null)
            {
                c--;
            }
            
            if(c!=c1)
            {
            for(int i=c1;i<=c;i++)
            {
              if(dans_pos(l,i)==true)
              {
                      s+=(board[l][i].getValLettre()*(board[l][i].getLettre().getValeur()));
                      p*=board[l][i].getValMot();
                     
              }
              else
              {
                s+=board[l][i].getLettre().getValeur();
                
              }
            }
           
            s=s*p;   
     }
     }
     }
     else
     {
     if(d==0)
     {
            l=maxl();
            c1=0;
            c=14;
            while(board[l][c1].getLettre()==null)
            {
                c1++;
            }
            while(board[l][c].getLettre()==null)
            {
                c--;
            }
            
            
            for(int i=c1;i<=c;i++)
            {
              if(dans_pos(l,i)==true)
              {
                      s+=(board[l][i].getValLettre()*(board[l][i].getLettre().getValeur()));
                      p*=board[l][i].getValMot();
                      
              }
              else
              {
                s+=board[l][i].getLettre().getValeur();
                
              }
            }
           
            s=s*p;
            
            for(int i=c1;i<=c;i++)
            {
                if(dans_pos(l,i)==true)
                {
                s1=0;p1=1;
                j=l;
               while(j!=0&&board[j-1][i].getLettre()!=null)
               {
               j--;  
               }
               x=j;
               //rechercher la fin du mot en vertical
               j=l;
               while(j!=14&&board[j+1][i].getLettre()!=null)
               {
               j++;   
               }
               x1=j;
               if(x!=x1)
               {
               for(int k=x;k<=x1;k++)
               {
                   if(k==l)
                   {
                 s1+=board[k][i].getLettre().getValeur()*board[k][i].getValLettre(); 
                 p1*=board[k][i].getValMot();
                
                   }
                   else
                       s1+=board[k][i].getLettre().getValeur();
                   
               }
               }
               s2+=s1*p1;       
              }
                
            }
            s+=s2;
           
     }

     else
     {
            l1=0;
            l=14;
            c=maxc();
            while(board[l1][c].getLettre()==null)
            {
                l1++;
            }
            while(board[l][c].getLettre()==null)
            {
                l--;
            }

            if(l!=l1)
            {
            for(int i=l1;i<=l;i++)
            {
                if(dans_pos(i,c)==true)
                {
                 s+=board[i][c].getValLettre()*board[i][c].getLettre().getValeur();
                 p*=board[i][c].getValMot();
               
                }
                else
                {
                   s+=board[i][c].getLettre().getValeur();
                   
                }
            }
            s*=p;
            
            }
            for(int i=l1;i<l;i++)
            { s1=0;p1=1;
               j=c;
               if(dans_pos(i,c)==true)
               {
               while(j!=0&&board[i][j-1].getLettre()!=null)
               {
               j--;  
               }
               x=j;
               //rechercher la fin du mot en vertical
               j=c;
               while(j!=14&&board[i][j+1].getLettre()!=null)
               {
               j++;   
               }
               x1=j;
               if(x!=x1)
               {
               for(int k=x;k<=x1;k++)
               {
                   if(k==c)
                   {
                 s1+=board[i][k].getLettre().getValeur()*board[i][k].getValLettre(); 
                 p1*=board[i][k].getValMot();
                 
                   }
                   else
                   {
                       s1+=board[i][k].getLettre().getValeur();
                       
                   }
               }
              
               }
            s2+=s1*p1;
          
            }
            }
            s+=s2;  
     }
     }
     
     return s;
 }

    private void ConstruirePlateau() {
         Icon caseSimple = new ImageIcon("../case2.JPG");
         Icon motCompteTriple = new ImageIcon("../MotTriple.JPG");
         Icon motCompteDouble = new ImageIcon("../MotCompteDouble.JPG");
         Icon lettreCompteDouble = new ImageIcon("../LettreCompteDouble2.JPG");
         Icon lettreCompteTriple = new ImageIcon("../LettreTriple2.JPG");
         Icon caseDepart = new ImageIcon("../Etoile.JPG");
         
        this.board[0][0] = new CaseVide(motCompteTriple,1,3,0,0,myDropTargetListener);
        this.board[7][0] = new CaseVide(motCompteTriple,1,3,7,0,myDropTargetListener);
        this.board[14][0] = new CaseVide(motCompteTriple,1,3,14,0,myDropTargetListener);
        this.board[0][7] = new CaseVide(motCompteTriple,1,3,0,7,myDropTargetListener);
        this.board[14][7] = new CaseVide(motCompteTriple,1,3,14,7,myDropTargetListener);
        this.board[0][14] = new CaseVide(motCompteTriple,1,3,0,14,myDropTargetListener);
        this.board[7][14] = new CaseVide(motCompteTriple,1,3,7,14,myDropTargetListener);
        this.board[14][14] = new CaseVide(motCompteTriple,1,3,14,14,myDropTargetListener);
        
        this.board[1][5] = new CaseVide(lettreCompteTriple,3,1,1,5,myDropTargetListener);
        this.board[1][9] = new CaseVide(lettreCompteTriple,3,1,1,9,myDropTargetListener);
        this.board[5][1] = new CaseVide(lettreCompteTriple,3,1,5,1,myDropTargetListener);
        this.board[5][5] = new CaseVide(lettreCompteTriple,3,1,5,5,myDropTargetListener);
        this.board[5][9] = new CaseVide(lettreCompteTriple,3,1,5,9,myDropTargetListener);
        this.board[5][13] = new CaseVide(lettreCompteTriple,3,1,5,13,myDropTargetListener);
        this.board[9][1] = new CaseVide(lettreCompteTriple,3,1,9,1,myDropTargetListener);
        this.board[9][5] = new CaseVide(lettreCompteTriple,3,1,9,5,myDropTargetListener);
        this.board[9][9] = new CaseVide(lettreCompteTriple,3,1,9,9,myDropTargetListener);
        this.board[9][13] = new CaseVide(lettreCompteTriple,3,1,9,13,myDropTargetListener);
        this.board[13][5] = new CaseVide(lettreCompteTriple,3,1,13,5,myDropTargetListener);
        this.board[13][9] = new CaseVide(lettreCompteTriple,3,1,13,9,myDropTargetListener);
        
        this.board[1][1] = new CaseVide(motCompteDouble,1,2,1,1,myDropTargetListener);
        this.board[2][2] = new CaseVide(motCompteDouble,1,2,2,2,myDropTargetListener);
        this.board[3][3] = new CaseVide(motCompteDouble,1,2,3,3,myDropTargetListener);
        this.board[4][4] =new CaseVide(motCompteDouble,1,2,4,4,myDropTargetListener);
        this.board[7][7] = new CaseVide(motCompteDouble,1,2,7,7,myDropTargetListener);
        this.board[10][10] =new CaseVide(motCompteDouble,1,2,10,10,myDropTargetListener);
        this.board[11][11] =new CaseVide(motCompteDouble,1,2,11,11,myDropTargetListener);
        this.board[12][12] = new CaseVide(motCompteDouble,1,2,12,12,myDropTargetListener);
        this.board[13][13] =new CaseVide(motCompteDouble,1,2,13,13,myDropTargetListener);
        this.board[1][13] =new CaseVide(motCompteDouble,1,2,1,13,myDropTargetListener);
        this.board[2][12] = new CaseVide(motCompteDouble,1,2,2,12,myDropTargetListener);
        this.board[3][11] = new CaseVide(motCompteDouble,1,2,3,11,myDropTargetListener);
        this.board[4][10] = new CaseVide(motCompteDouble,1,2,4,10,myDropTargetListener);
        this.board[10][4] = new CaseVide(motCompteDouble,1,2,10,4,myDropTargetListener);
        this.board[11][3] = new CaseVide(motCompteDouble,1,2,11,3,myDropTargetListener);
        this.board[12][2] = new CaseVide(motCompteDouble,1,2,12,2,myDropTargetListener);
        this.board[13][1] = new CaseVide(motCompteDouble,1,2,13,1,myDropTargetListener);
        
        this.board[0][3] = new CaseVide(lettreCompteDouble,2,1,0,3,myDropTargetListener);
        this.board[0][11] = new CaseVide(lettreCompteDouble,2,1,0,11,myDropTargetListener);
        this.board[2][6] = new CaseVide(lettreCompteDouble,2,1,2,6,myDropTargetListener);
        this.board[2][8] = new CaseVide(lettreCompteDouble,2,1,2,8,myDropTargetListener);
        this.board[3][0] = new CaseVide(lettreCompteDouble,2,1,3,0,myDropTargetListener);
        this.board[3][7] = new CaseVide(lettreCompteDouble,2,1,3,7,myDropTargetListener);
        this.board[3][14] =new CaseVide(lettreCompteDouble,2,1,3,14,myDropTargetListener);
        this.board[6][2] = new CaseVide(lettreCompteDouble,2,1,6,2,myDropTargetListener);
        this.board[6][6] = new CaseVide(lettreCompteDouble,2,1,6,6,myDropTargetListener);
        this.board[6][8] = new CaseVide(lettreCompteDouble,2,1,6,8,myDropTargetListener);
        this.board[6][12] = new CaseVide(lettreCompteDouble,2,1,6,12,myDropTargetListener);
        this.board[7][3] = new CaseVide(lettreCompteDouble,2,1,7,3,myDropTargetListener);
        this.board[7][11] = new CaseVide(lettreCompteDouble,2,1,7,11,myDropTargetListener);
        this.board[8][2] =new CaseVide(lettreCompteDouble,2,1,8,2,myDropTargetListener);
        this.board[8][6] = new CaseVide(lettreCompteDouble,2,1,8,6,myDropTargetListener);
        this.board[8][8] = new CaseVide(lettreCompteDouble,2,1,8,8,myDropTargetListener);
        this.board[8][12] = new CaseVide(lettreCompteDouble,2,1,8,12,myDropTargetListener);
        this.board[11][0] = new CaseVide(lettreCompteDouble,2,1,11,0,myDropTargetListener);
        this.board[11][7] = new CaseVide(lettreCompteDouble,2,1,11,7,myDropTargetListener);
        this.board[11][14] = new CaseVide(lettreCompteDouble,2,1,11,14,myDropTargetListener);
        this.board[12][6] = new CaseVide(lettreCompteDouble,2,1,12,6,myDropTargetListener);
        this.board[12][8] = new CaseVide(lettreCompteDouble,2,1,12,8,myDropTargetListener);
        this.board[14][3] = new CaseVide(lettreCompteDouble,2,1,14,3,myDropTargetListener);
        this.board[14][11] = new CaseVide(lettreCompteDouble,2,1,14,11,myDropTargetListener);
        this.board[7][7]=new CaseVide(caseDepart,1,1,7,7,myDropTargetListener);
        for (int i = 0; i < 15; i++) {
            for (int j = 0; j < 15; j++) {
                if (this.board[i][j] == null)                      
                    this.board[i][j] =new CaseVide(caseSimple,1,1,i,j,myDropTargetListener);
                
                reinitialiser();
            }
        }
        

        
        for(int i=0;i<15;i++)
{
	for( int j=0;j<15;j++)
	{
        board[i][j].setBounds(40*j,40*i, 40, 40);
       
     

        this.add(board[i][j]);

	}
       
        
}
     
        
            }
 
    public void reinitialiser()
        {
           
            
          ipos=0;  
          for(int i=0;i<7;i++)
          {  pos[0][i]=-1;
          pos[1][i]=-1;

          
          
        }
          
        
       

}
   public void  reinitialserChevalet()
    {
       int i=0;
       while(i<ipos)
       {
            try{
           ch.ajouterItem(board[pos[0][i]][pos[1][i]]);
           board[pos[0][i]][pos[1][i]].setImagecon();
           board[pos[0][i]][pos[1][i]].setLettre(null);
             board[pos[0][i]][pos[1][i]].setDropTarget(true);
           i++;
           }
           catch(Exception e){}
       }
           
    }
    public void setPos(int i,int j)
    {
    pos[0][ipos]=i;
    pos[1][ipos]=j;
    ipos++;
   
    
    }
    public void setPos(CaseVide c)
    {int i=0;
    
        while(i<ipos && pos[0][i]!=c.getPosLigne() || pos[1][i]!=c.getPosColonne())
           i++;
        if(i!=ipos)
        { for(int j=i;j<ipos-1;j++)
         {
             pos[0][j]=pos[0][j+1];
             pos[1][j]=pos[1][j+1];
         }
            ipos--;
    }
        
    }
    

    CaseVide chercherLettre(char c) {
       int i=0;
       int j=0;
 
       while(i<15)
       { j=0;
       while(j<15)
           { 
           {if(board[i][j].getLettre()!=null)
           {if(board[i][j].getLetNom()==c)
               {   
                   return board[i][j];
               }
           }
              
            
           j++;
           
           }
    }
       i++;
    }
       return null;
}

    CaseVide rechercherJoker() {
              int i=0;
       int j=0;
    
       while(i<15)
       { j=0;
       while(j<15)
           { 
           {if(board[i][j].getLettre()!=null)
           {if(board[i][j].getLettre().isJoker())
               {   
                   return board[i][j];
               }
           }
              
            
           j++;
           
           }
    }
       i++;
    }
       return null;
}
    }
    
    
